<?php
#Template for Choose a plan. 
$page = (isset($page)) ? $page : 'cplans';
include "inc/local_data.php";
$form = (isset($using_real_env) && $using_real_env) ? $form : ((isset($data[$page])) ? $data[$page] : array());
if (empty($form)) exit;

?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title><?php echo $form['title'];?></title>
		<?php include('inc/embed_top.php');?>
    </head>
    <body mlang="<?php echo $form['lang'];?>">
        <div id="cplan" class="<?php echo $form['lang'];?>" data-role="page" data-theme="f">
            <div class="ltit"><span class="logo">&nbsp;</span><span class="r">tvb.com</span></div>
            <h1>
                <?php echo $form['cplan_title'];?>
                <?php 
                    if (isset($form['is_logined']) && $form['is_logined']) {
                ?>
                        <a ajax="<?php echo $form['button']['cancel']['link'];?>" class="cancel logout" href="#" rel="external" data-role="button"><?php echo $form['button']['cancel']['value'];?></a>
                <?php
                    }
                ?>
            </h1>
            <?php include('inc/inc.step.php');?>
            <ul class="com-plan" data-role="listview" data-theme="f">
            <?php
                if (!empty($form['package_lists'])) {
                    $rows = NULL;
                    foreach((array)$form['package_lists']  as $pid=>$p_val) {
                        $pkg_urls = NULL;
                        if (!$form['from_local']) {
                            $unit_txt      = OAuthModelConfig::getRealUnit($p_val['unit'],$p_val['duration'],$lang,$p_val['free_period']);
                            $dollar_char   = strtoupper(substr($p_val['currency_code'],0,2)).'$';
                            $free_aver_txt = OAuthModelConfig::getFreePeriodPlan($p_val['free_period'],$lang,$p_val['duration'],$p_val['unit'],$p_val['price'],$dollar_char);                           
                            $plan_info     = json_encode($p_val);
                            $pkg_urls      = $submit_get_url.'&pkg_id='.$p_val['id'].'&pkg_v='.$p_val['version'].'&pkg_price='.$p_val['price'];
                            $price_str     = ($p_val['price']!=0) ? $dollar_char.$p_val['price'] : NULL;
                        }
                        else {
                            $base_url      = ($login_status) ? 'information.html' : 'joins_plan.html';
                            $base_url      = 'information.html';
                            $pkg_urls      = $base_url.'?plan='.($pid+1);
                            $unit_txt      = $p_val['duration'].$p_val['unit'];
                            $dollar_char   = 'US$';
                            $free_aver_txt = $p_val['free_txt'];
                            $price_str     = ($p_val['price']!=0) ? $dollar_char.$p_val['price'] : NULL;
                        }

                        //output rows for ever package. 
                        $rows .= "<li>".
                                 "  <a href='".$pkg_urls."' rel='external'><h2>".$p_val['title']."</h2><p>".$unit_txt."</p><p>".$p_val['description']."</p><p>".$price_str."<em> ".$free_aver_txt."</em></p></a>".
                                 "</li>";
                    }
                    echo $rows;
                }
                else {
                    echo '<li><p>'.$form['cplan_null'].'</p></li>';
                }
            ?>
            </ul>
            <div class="note">
                <?php echo $form['cplan_note'];?>
    		</div>
		</div>
		<?php include('inc/embed_bottom.php');?>
    </body>
</html>
